package cn.yomigaeri.warn.consumer;

import cn.yomigaeri.common.entity.dto.SignalDTO;

import cn.yomigaeri.common.entity.dto.WarnDTO;
import cn.yomigaeri.warn.service.WarnSignalService;
import cn.yomigaeri.warn.service.impl.WarnSignalServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;


/**
 * @ClassName: SignalConsumer
 * @Package: cn.yomigaeri.upload.consumer
 * @Description:
 * @Author Yomigaeri
 * @Create 2025/6/4 21:45
 * @Version 1.0
 */
@Service
@Slf4j
@RequiredArgsConstructor
@RocketMQMessageListener(
        topic = "signalToCheck",
        consumerGroup = "warn-consumer"
)
public class SignalConsumer implements RocketMQListener<SignalDTO> {

    private final WarnSignalService warnSignalService;

    @Override
    public void onMessage(SignalDTO signalDTO) {
        WarnDTO warnDTO = warnSignalService.checkSignal(signalDTO);
        if (warnDTO != null) {
            log.info("检测到异常：{}", warnDTO);
        }

    }
}
